<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // js快速取整
      // console.log(~~4.4);

      // 交换变量
      /* let a = "4",
        b = "5";
      a = a ^ b;
      b = a ^ b;
      a = a ^ b;
      console.log(a, b); */

      // 位的开关
      const perm = {
        read: 1,
        write: 2,
        create: 4,
      };

      // 可读可写
      let p = perm.read | perm.write;

      // 去掉权限
      p = (p | perm.read) ^ perm.read;

      // 判断权限
      console.log((p & perm.read) === perm.read);
    </script>
  </body>
</html>
